/**
 * 
 */
package dao;

import java.sql.SQLException;

import utils.Const;
import com.j256.ormlite.dao.Dao;
import database.DatabaseHelper;
import entity.Account;
import entity.Category;

/**
 * @author Hung
 *
 */
public class CategoryDAO {
	
	private Dao<Category, Integer> dao = null;
	
	public CategoryDAO(DatabaseHelper helper) throws Exception {
		dao = helper.getCategoryDao();
		if (dao == null)
			throw new Exception(Const.NULL_DAO_ERROR);
	}
	
	public int createCategory(Category category) throws SQLException {
		return dao.create(category);
	}
	
	public int updateCategory(Category category) throws SQLException {
		return dao.update(category);
	}
	
	public int deleteCategory(Category category) throws SQLException {
		return dao.delete(category);
	}
	
	public Category getCategoryById(int id) throws SQLException {
		return dao.queryForId(id);
	}
}
